package com.JSON;


import com.alibaba.fastjson.JSONObject;

import java.util.Arrays;
import java.util.List;

/**
 * 从 Java 变量到 JSON 格式的编码过程
 * @author shkstart
 * @creat 2022-05-16:39
 */
public class ToJSONTest {
    public static void main(String[] args) {
        JSONObject object = null;

            object = new JSONObject();
            //string
            object.put("string","string");
            //int
            object.put("int",2);
            //boolean
            object.put("boolean",true);
            //array
            List<Integer> integers = Arrays.asList(1,2,3);
            object.put("list",integers);
            //null
            //并不显示
            object.put("null",null);
            System.out.println(object);

    }
}
